    //ajax的发送
 function  registerlogin() {
	//获取请求参数
	 var username = $("#userName").val().trim();
	 var password = $("#password").val().trim();
	 var surepassword=$("#surePassword").val().trim();
	//alert(username+":"+password+":"+surepassword)//验证：打印用户名和密码
	 $("#username_span").html("");
	 $("#password_span").html("");
	 $("#surepassword_span").html("");
	 var ok = true;
	 if(username == null || username == ""){
			$("#username_span").html("用户名不能为空");
			ok = false;
		}		
	    
		if (password == null || password == "") {
			$("#password_span").html("密码不能为空");
			
			ok = false;
		}
		 if(password.length< 4){
				$("#password_span").html("密码大于四位数");
				ok = false;
			}
		if(surepassword == null || surepassword == ""){
			$("#surepassword_span").html("确认密码不能为空");
			ok = false;
		}
		if(password != surepassword){
			$("#surepassword_span").html("两次输入的密码不一致");
			ok = false;
		}
		
		if(ok){
			
			$.ajax({
				
				//http://localhost:8080/commodity/user/register.do
				url: path+"/user/register.do",
				type:"post",
				data:{"username":username,"password":password},
				dataType:"json",
				
				success:function(result){
					//result是服务器端返回的Json数据
					if (result.status == 0) {
						window.location.href = "login.jsp";
					}else if(result.status == 1){
						$("#username_span").html(result.msg);
					}else if (result.status == 2) {
						$("#password_span").html(result.msg);
					}
					
				},
				error:function(){
					alert("登录失败");
				}
			});
			
		}
		    	
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    